#include "util.hpp"
#include "level.hpp"
#include "message.hpp"
#include "format.hpp"
#include "sink.hpp"

int main()
{
    // std::cout << bitlog::util::Date::getTime() << std::endl;
    // std::string pathname = "./abc/bcd/a.txt";
    // bitlog::util::File::createDirectory(bitlog::util::File::path(pathname));
    // std::cout << bitlog::LogLevel::toString(bitlog::LogLevel::value::DEBUG) << std::endl;
    // std::cout << bitlog::LogLevel::toString(bitlog::LogLevel::value::INFO) << std::endl;
    // std::cout << bitlog::LogLevel::toString(bitlog::LogLevel::value::WARN) << std::endl;
    // std::cout << bitlog::LogLevel::toString(bitlog::LogLevel::value::ERROR) << std::endl;
    // std::cout << bitlog::LogLevel::toString(bitlog::LogLevel::value::FATAL) << std::endl;
    // std::cout << bitlog::LogLevel::toString(bitlog::LogLevel::value::OFF) << std::endl;
    bitlog::LogMsg msg(bitlog::LogLevel::value::INFO, 53, "main.c", "root", "格式化功能测试...");
    bitlog::Formatter fmt;
    std::string str = fmt.format(msg);
    //std::cout << str << std::endl;
    bitlog::LogSink::ptr stdout_lsp = bitlog::SinkFactory::create<bitlog::StdoutSink>();
    bitlog::LogSink::ptr file_lsp = bitlog::SinkFactory::create<bitlog::FileSink>("./logfile/test.log");
    bitlog::LogSink::ptr roll_lsp = bitlog::SinkFactory::create<bitlog::RollBySizeSink>("./logfile/roll-", 1024*1024);
    stdout_lsp->log(str.c_str(), str.size());
    file_lsp->log(str.c_str(), str.size());
    size_t cursize = 0;
    size_t count = 0;
    while(cursize < 1024 * 1024 * 10) {
        std::string tmp = str + std::to_string(count++); // 换行在str末尾处
        roll_lsp->log(tmp.c_str(), tmp.size());
        cursize += tmp.size();
    }


}